<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="util.DBConnect" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ page import="java.sql.*" %>
<title>Insert title here</title>
</head>
	<link rel="stylesheet" href="css/amazeui.min.css">
    <link rel="stylesheet" href="css/petshow.css?6">
    <link rel="stylesheet" href="css/animate.min.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/amazeui.min.js"></script>
    <script src="js/amazeui.lazyload.min.js"></script>
<body>
<form>
<%@include file="MenuBar.jsp" %>
<div>
<table border="1" align="center">
<tr height="15">
<th>菜品名称</th>
<th>菜品价格</th>
<th>商家</th>
<th>库存</th>
<th>菜品描述</th>

</tr>
<%
Connection conn=DBConnect.MySQLConnect();
try{
	int s_id=Integer.parseInt(request.getParameter("s_id"));
    Statement stmt=conn.createStatement();
    String sql="select * from fooditem where s_id="+s_id;
    ResultSet rs=stmt.executeQuery(sql);
    int i=0;
    List<String> cartItem=new ArrayList<String>();
    session.setAttribute("Item", cartItem);
    List<String> itemName=new ArrayList<String>();
    List<String> itemPrice=new ArrayList<String>();
    List<String> itemStoreName=new ArrayList<String>();
    List<String> itemStorage=new ArrayList<String>();
    List<String> itemDescription=new ArrayList<String>();
    while(rs.next()){
    	itemName.add(rs.getString("fi_name"));
    	itemPrice.add(rs.getString("fi_price"));
    	itemStoreName.add(rs.getString("s_name"));
    	itemStorage.add(rs.getString("fi_storage"));
    	itemDescription.add(rs.getString("fi_description"));
    	
    
%>
<tr>
<td height="50" name="ci_name"><%=itemName.get(i) %></td>
<td name="ci_itemPrice"><%=itemPrice.get(i)%></td>
<td><%=itemStoreName.get(i)%></td>
<td><%=itemStorage.get(i)%></td>
<td><%=itemDescription.get(i)%></td>
<td><%=i%></td>
<td></td>
<td> <button><a href="AddItemServlet?ci_name=<%=itemName.get(i) %>&ci_itemPrice=<%=itemPrice.get(i)%>&ci_cartId=2&s_id=<%=s_id%>" onClick="return confirm('确定加入购物车吗?');">加入购物车</a></button></td>
</tr>

 <input type="hidden" id="a" value="<%=itemName.get(i) %>">
 <input type="hidden" id="b" value="<%=itemPrice.get(i)%>">
  <input type="hidden" id="c" value="30">

<script>
var ci_name=document.getElementById('a').value;
var ci_itemPrice=document.getElementById('b').value;
var ci_cartId=document.getElementById('c').value;
function food(){
	alert(ci_name);
	alert(ci_itemPrice);
	//window.location.href='AddItemServlet?ci_name='+ci_name+'&ci_itemPrice='+ci_itemPrice+'&ci_cartId'+ci_cartId;
	
	//window.location.href="http://localhost:8080/OrderingSystem/AddItemServlet?ci_name="+ci_name+'&ci_itemPrice=' + ci_itemPrice;
}

function addIntoCart(o){
	//alert(i);
	alert(o.value+"已加入购物车");
	window.location.href = "submit.jsp?btnname="+o.value;
}
</script>
<%
i++;
    }
}
catch(Exception e) {
    e.printStackTrace();
   } 
%>
</table>
</div>
<%@include file="FooterInfo.jsp" %>
</form>
</body>
</html>